Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

404
Vistas
ClientError: Unable to parse value of "$tweetId=undefined". Please quote string values

I am using sanity, also if you need more information I will provide it as soon as possible. When I go to http://localhost:3000/api/getComments it writes me that error:

ClientError: Unable to parse value of "$tweetId=undefined". Please quote string values.

fetchComments.ts

import { Comment } from "../typings"

export const fetchComments = async (tweetId: string) => {
     const res = await fetch(`/api/getComments?tweetId=${tweetId}`)

     const comments: Comment[] = await res.json()

     return comments
}

getComments.ts

import type { NextApiRequest, NextApiResponse } from "next";
import { groq } from "next-sanity";
import { sanityClient } from "../../sanitytwitter/sanity";
import { Comment } from "../../typings";

const commentQuery = groq`
*[_type == "comment" && references(*[_type == 'tweet' && _id == $tweetId]._id )]
{
    _id,
    ...
} | order(_createdAt desc)
`

type Data = Comment[]

export default async function handler(
    req: NextApiRequest,
    res: NextApiResponse<Data>
) {
    const { tweetId } = req.query;

    const comments: Comment[] = await sanityClient.fetch(commentQuery, {
        tweetId,
    })

    res.status(200).json(comments)
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda